<template>
	<view>
		<uni-nav-bar left-icon="left" fixed statusBar title="导航栏组件"></uni-nav-bar>
		课程名称：{{detailInfo.className}}
		<button @click="doShare">分享</button>
		<button open-type="share">我要分享这个课程</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataId: '',
				detailInfo: {
					className: ''
				}
			}
		},
		onLoad(options) {
			console.log(options)
			const eventChanle = this.getOpenerEventChannel()
			eventChanle.on('acceptDataFromOpenerPage',(data) => {
				console.log(data)
			})
			this.dataId = options.id
			if(options.from==='share') {
				uni.showToast({
					title: '从分享页进来的'
				})
			}
			uni.hideShareMenu()
			this.getDetail()
		},
		onShareAppMessage() {
			return {
				title: 'vue课程分享的标题',
				path: '/pages/detail/detail?from=share',
				imageUrl: 'https://t7.baidu.com/it/u=1819248061,230866778&fm=193&f=GIF',
				content: '1',
				desc: '2',
				success:(res) => {
					console.log(res)
					uni.showToast({
						title:'分享成功了'
					})
				}
			}
		},
		methods: {
			//发请求获取详情信息
			getDetail() {
				console.log(this.dataId)
				setTimeout(() => {
					this.detailInfo = {
						className: '这是vue课程详情'
					}
				}, 1000)
				// uni.request({
				// 	url:
				// })
			},
			doShare() {
				uni.showShareMenu({
					title: '测试分享按钮'
				})
			}
		}
	}
</script>

<style>

</style>
